package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.pojo.Result;
import org.example.utils.HuaweiOBSUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 包名：org.example.controller
 * 用户：admin
 * 日期：2025-09-12
 * 项目名称：pro-demo
 */
@Slf4j
@RestController
public class UploadController {

    @Autowired
    private HuaweiOBSUtils huaweiOBSUtils;

    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws Exception {
        log.info("文件上次：{}", image.getOriginalFilename());
        String url = huaweiOBSUtils.upload(image);
        log.info("文件上传完成，文件访问的url：{}",url);
        return Result.success(url);
    }
}
